using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using System.Data;
using System.Data.OleDb;

namespace DAO
{
    public class P_QUIDINHSOTIETKIEM_DAO
    {
        public DataTable P_LoadDanhSachLoaiTietKiem()
        {
            DataTable dt;
            DataProvider dp = new DataProvider();
            dt = dp.ExecuteQuery("Select * From LOAITIETKIEM");
            return dt;
        }
        public DataTable P_LoadQuiDinh()
        {
            DataTable dt;
            DataProvider dp = new DataProvider();
            dt = dp.ExecuteQuery("Select * From QUIDINH");
            return dt;
        }

        //Them loai tiet kiem moi
        public void P_ThemLoaiTietKiemMoi(P_QUIDINHSOTIETKIEM_DTO pltk)
        {
            string sql = "Insert into LOAITIETKIEM(TenLoaiTietKiem,LaiSuat) Values (" + pltk.PTenLoaiTietKiem.ToString() + "," + pltk.PLaiSuat.ToString() + ")";
            DataProvider dp = new DataProvider();
            dp.ExecuteNonQuery(sql);
        }

        public void P_CapNhatQuiDinh(P_QUIDINHSOTIETKIEM_DTO pdto)
        {
            string sql = " Update QUIDINH Set TienGuiToiThieu=" + pdto.PTienGuiToiThieu.ToString() + ",ThoiGianGuiToiThieu =" + pdto.PThoiGianGuiToiThieu.ToString() + ",SoLuongLoaiKyHan=" + pdto.PSoLuongLoaiKyHan.ToString() + " Where MQD = 1 ";
            DataProvider dp = new DataProvider();
            dp.ExecuteNonQuery(sql);
        }

        public void P_CapNhatLaiSuat(P_QUIDINHSOTIETKIEM_DTO pls)
        {
            string sql = " Update LOAITIETKIEM set LaiSuat=" + pls.PLaiSuat.ToString() + " Where MLTK =" + pls.PMLTK.ToString();
            DataProvider dp = new DataProvider();
            dp.ExecuteNonQuery(sql);
        }

        public DataTable P_SoLuongLTK()
        {
            DataTable dt = new DataTable();
            string sql = "Select * From LOAITIETKIEM";
            DataProvider dp = new DataProvider ();
            dt = dp.ExecuteQuery(sql);
            return dt;
        }
    }
}
